/*
 * DatagramBuilder Library: serialize/deserialize data to/from datagram
 * Copyright (C) 2008 Rakov Ilya <RakovIlya@gmail.com>
 *
 * This library can be distributed under the terms of the GNU LGPLv2.
 * See the file COPYING.LIB.
 */


#ifndef DATAGRAM_TAG_H_
#define DATAGRAM_TAG_H_


/**
 * @file Tag.h
 *
 * @brief Tag header file
 *
 * @date Dec 4, 2008
 * @author Rakov Ilya
 */


/**
 * @brief This class provides an ability to tag value.
 *
 * The "Tagged Value" is a value with a prepended value data type identifier.
 * I.e. the "Tag" is a data type identifier.
 * This ability might be used for the data consistency checking.
 */
template < class T > struct Tag
{
  explicit Tag( T &value ): value_( value )
  {
  }

  T &value_;
};


/**
 * @brief Helper function for creation instances of the Tag.
 */
template < class T > inline Tag< T > tag( T &value )
{
  return Tag< T >( value );
}


/**
* @brief Helper function for creation instances of the Tag.
 */
template < class T > inline Tag< const T > tag( const T &value )
{
  return Tag< const T >( value );
}


#endif /* DATAGRAM_TAG_H_ */
